<?php
defined('BASEPATH') OR exit('No direct script access allowed');

class Setting extends User_Controller {

	public function __construct()
    {
        parent::__construct();
        // Your own constructor code
    }

	function info(){
		$token = get_qiniu_token('VIMG');
		$this->smarty->assign("token", $token);
		$this->load->model('Student_model');

		$post_data = $this->input->post();
		if($post_data){
			if(!empty($post_data['head_image_url'])){
				$post_data['head_image_url'] = get_qiniu_url($post_data['head_image_url']);
			}
			$this->Student_model->update_student_info($this->user_data['id'],$post_data);
			header("Location:/user/setting/info");exit;
		}
		//获取学员信息
		
		$student = $this->Student_model->get_student_by_userid($this->user_data['id']);
		$this->smarty->assign("student", $student);
		// print_r(in_array(0,json_decode($student['class_time'])));exit;

		//获取省
		$this->load->model('Area_model');
		$province = $this->Area_model->get_list();
		$this->smarty->assign("province", $province);

		//获取城市
		if(isset($student)&&!empty($student['province'])){
			$city = $this->Area_model->get_list($student['province']);
			$this->smarty->assign("city", $city);
		}
		//获取区
		if(isset($student)&&!empty($student['city'])){
			$district = $this->Area_model->get_list($student['city']);
			$this->smarty->assign("district", $district);
		}

		$this->smarty->assign("menu", "setting");
		$this->smarty->display("user/account_info.html");
	}

	function get_area_by_parent($parent_code){
		$this->load->model('Area_model');
		$area = $this->Area_model->get_list($parent_code);
		print_r(json_encode($area));exit;
	}

	function account(){

		$this->smarty->assign("menu", "setting");
		$this->smarty->assign("mobile", $this->user_data['mobile']);
		$this->smarty->display("user/account_setting.html");
	}

}